package org.data12.SpringbootDemo.config;

import org.data12.SpringbootDemo.interceptor.LoginInterceptor;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

public class LoginInterceptorConfig implements WebMvcConfigurer {
    public void addInterceptors(InterceptorRegistry registry){
        HandlerInterceptor interceptor = new LoginInterceptor();
        List<String> patters = new ArrayList<>();
        patters.add("/static/**");
        patters.add("/login");
        patters.add("/loginCheck");
        registry.addInterceptor(interceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(patters);
    }
}
